package com.landeb.shop.huo;

import android.content.Context;
import android.content.pm.PackageManager;

/**
 * Created by blade on 2017/8/24.
 */

public class VersionManager {

    public static String getVersionName(Context context) {
        String versionName = "";

        try {
// 获取软件版本号，对应AndroidManifest.xml下的versionCode
            versionName = context.getPackageManager().getPackageInfo("com.landeb.shop", 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionName;
    }

    public static int getVersionCode(Context context) {
        int versionCode = 0;

        try {
// 获取软件版本号，对应AndroidManifest.xml下的versionCode
            versionCode = context.getPackageManager().getPackageInfo("com.landeb.shop", 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionCode;
    }
}
